// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   MakeQSObjectPool.java

package org.quickserver.util.pool;

import java.util.*;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.PoolableObjectFactory;

// Referenced classes of package org.quickserver.util.pool:
//            QSObjectPool, QSObjectPoolMaker

public class MakeQSObjectPool
    implements QSObjectPool, QSObjectPoolMaker
{

    public QSObjectPool getQSObjectPool(ObjectPool objectPool)
    {
        return new MakeQSObjectPool(objectPool);
    }

    public MakeQSObjectPool()
    {
        objectPool = null;
        list = null;
    }

    public MakeQSObjectPool(ObjectPool objectPool)
    {
        this.objectPool = null;
        list = null;
        setObjectPool(objectPool);
    }

    protected void setObjectPool(ObjectPool objectPool)
    {
        this.objectPool = objectPool;
        list = Collections.synchronizedList(new LinkedList());
    }

    public void returnObject(Object obj)
        throws Exception
    {
        list.remove(obj);
        objectPool.returnObject(obj);
    }

    public Object borrowObject()
        throws Exception
    {
        Object obj = objectPool.borrowObject();
        list.add(obj);
        return obj;
    }

    public synchronized void close()
        throws Exception
    {
        list.clear();
        objectPool.close();
    }

    public Iterator getAllActiveObjects()
    {
        return list.iterator();
    }

    public Object getObjectToSynchronize()
    {
        return list;
    }

    public void addObject()
        throws Exception
    {
        objectPool.addObject();
    }

    public void clear()
        throws Exception
    {
        objectPool.clear();
    }

    public int getNumActive()
    {
        return objectPool.getNumActive();
    }

    public int getNumIdle()
    {
        return objectPool.getNumIdle();
    }

    public void invalidateObject(Object obj)
        throws Exception
    {
        objectPool.invalidateObject(obj);
    }

    public void setFactory(PoolableObjectFactory factory)
    {
        objectPool.setFactory(factory);
    }

    protected ObjectPool objectPool;
    protected List list;
}
